]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st: Only notify on property changes
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 3 Jun 2022 18:32:03 +0000 (20:32 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 8 Jun 2022 14:16:28 +0000 (14:16 +0000)
Since commit 5a23c96bd918 we use EXPLICIT_NOTIFY for properties,
however there are still cases where we still notify unconditionally
from the setter, because we don't check the existing value first.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2325>

src/st/st-button.c
src/st/st-entry.c
src/st/st-icon.c
src/st/st-widget.c

index c04a70eb69986528f106d33fed764c1d8287cb45..148197c24c2218d8b51bae519dacf473cb3573b3 100644 (file)
@@ -662,6 +662,9 @@ st_button_set_label (StButton    *button,
 
   priv = st_button_get_instance_private (button);
 
+  if (g_strcmp0 (priv->text, text) == 0)
+    return;
+
   g_free (priv->text);
 
   if (text)
@@ -739,6 +742,9 @@ st_button_set_icon_name (StButton   *button,
 
   if (ST_IS_ICON (icon))
     {
+      if (g_strcmp0 (st_icon_get_icon_name (ST_ICON (icon)), icon_name) == 0)
+        return;
+
       st_icon_set_icon_name (ST_ICON (icon), icon_name);
     }
   else
@@ -788,6 +794,10 @@ st_button_set_button_mask (StButton     *button,
   g_return_if_fail (ST_IS_BUTTON (button));
 
   priv = st_button_get_instance_private (button);
+
+  if (priv->button_mask == mask)
+    return;
+
   priv->button_mask = mask;
 
   g_object_notify_by_pspec (G_OBJECT (button), props[PROP_BUTTON_MASK]);
@@ -826,6 +836,10 @@ st_button_set_toggle_mode (StButton *button,
   g_return_if_fail (ST_IS_BUTTON (button));
 
   priv = st_button_get_instance_private (button);
+
+  if (priv->is_toggle == toggle)
+    return;
+
   priv->is_toggle = toggle;
 
   g_object_notify_by_pspec (G_OBJECT (button), props[PROP_TOGGLE_MODE]);
@@ -864,15 +878,15 @@ st_button_set_checked (StButton *button,
   g_return_if_fail (ST_IS_BUTTON (button));
 
   priv = st_button_get_instance_private (button);
-  if (priv->is_checked != checked)
-    {
-      priv->is_checked = checked;
+  if (priv->is_checked == checked)
+    return;
 
-      if (checked)
-        st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked");
-      else
-        st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked");
-    }
+  priv->is_checked = checked;
+
+  if (checked)
+    st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked");
+  else
+    st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked");
 
   g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CHECKED]);
 }
index 625bbf2523e6c93a71df8f66599510f5860c4b56..64f85fd516deb0aeb7ae51db53c57deef48d6e83 100644 (file)
@@ -1400,6 +1400,9 @@ st_entry_set_primary_icon (StEntry      *entry,
 
   priv = st_entry_get_instance_private (entry);
 
+  if (priv->primary_icon == icon)
+    return;
+
   _st_entry_set_icon (entry, &priv->primary_icon, icon);
   g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_PRIMARY_ICON]);
 }
@@ -1440,6 +1443,9 @@ st_entry_set_secondary_icon (StEntry      *entry,
 
   priv = st_entry_get_instance_private (entry);
 
+  if (priv->secondary_icon == icon)
+    return;
+
   _st_entry_set_icon (entry, &priv->secondary_icon, icon);
   g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_SECONDARY_ICON]);
 }
@@ -1480,6 +1486,9 @@ st_entry_set_hint_actor (StEntry      *entry,
 
   priv = ST_ENTRY_PRIV (entry);
 
+  if (priv->hint_actor == hint_actor)
+    return;
+
   if (priv->hint_actor != NULL)
     {
       clutter_actor_remove_child (CLUTTER_ACTOR (entry), priv->hint_actor);
index f7586b94718c1ce3157981f3ea9e28a4884e5cb6..6009afec50833a178401717c0891ef71fca3f4f4 100644 (file)
@@ -638,6 +638,9 @@ st_icon_set_icon_name (StIcon      *icon,
 
   g_return_if_fail (ST_IS_ICON (icon));
 
+  if (g_strcmp0 (icon_name, st_icon_get_icon_name (icon)) == 0)
+    return;
+
   if (icon_name && *icon_name)
     gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
 
@@ -815,6 +818,9 @@ st_icon_set_fallback_icon_name (StIcon      *icon,
 
   g_return_if_fail (ST_IS_ICON (icon));
 
+  if (g_strcmp0 (fallback_icon_name, st_icon_get_fallback_icon_name (icon)) == 0)
+    return;
+
   if (fallback_icon_name && *fallback_icon_name)
     gicon = g_themed_icon_new_with_default_fallbacks (fallback_icon_name);
 
index f50be949afbe2947c1e9872912c3c77e88cb5f1a..92d6456a1997ca842529a201ab3ced352df45da1 100644 (file)
@@ -2434,6 +2434,9 @@ st_widget_set_accessible_name (StWidget    *widget,
 
   priv = st_widget_get_instance_private (widget);
 
+  if (g_strcmp0 (name, priv->accessible_name) == 0)
+    return;
+
   if (priv->accessible_name != NULL)
     g_free (priv->accessible_name);
 
@@ -2490,6 +2493,10 @@ st_widget_set_accessible_role (StWidget *widget,
   g_return_if_fail (ST_IS_WIDGET (widget));
 
   priv = st_widget_get_instance_private (widget);
+
+  if (priv->accessible_role == role)
+    return;
+
   priv->accessible_role = role;
 
   g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_ACCESSIBLE_ROLE]);